package org.cptz.game.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.apache.ibatis.annotations.Mapper;

public class CodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/oriental_bridge?serverTimezone=UTC", "root", "123456")
                .globalConfig(builder -> {
                    builder.author("cpt.z") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .outputDir("E:\\IdeaProjects\\OrientalBridge\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("org.cptz.game"); // 设置父包名
                })
                .strategyConfig(builder -> {
                    builder.addInclude("Stand", "Player", "Match", "Match_Player", "Match_Detail") // 设置需要生成的表名
                            .entityBuilder().enableLombok().enableChainModel().enableFileOverride()
                            .mapperBuilder().mapperAnnotation(Mapper.class).enableFileOverride()
                            .serviceBuilder().enableFileOverride()
                            .controllerBuilder().enableRestStyle().enableFileOverride();
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
